home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cenvid9.zip / ISDAY_1.BAT < prev    next >
DOS Batch File  |  1994-03-04  |  2KB  |  43 lines

  1. @echo OFF
  2. REM **********************************************************************
  3. REM *** IsDay_1.bat - Display message about whether it is The WeekDay  ***
  4. REM *** ver.1         requested, and set ERRORLEVEL to 1 if it is else ***
  5. REM ***               0 if it is not.                                  ***
  6. REM **********************************************************************
  7. cenvi %0.bat %1 %2
  8. GOTO CENVI_EXIT
  9.  
  10. main(argc,argv)
  11. {
  12.    IsDay = 0                           // Assume that it is not the correct day
  13.    if ( argc != 2  ||  strlen(argv[1]) < 3 ) {
  14.       // Invalid parameters were passed, and so explain how to use this program
  15.       ShowHelp()
  16.    } else {
  17.       TimeString = ctime(time())       // Standard C functions to get NOW as a string
  18.       strcpy(QueryDay,argv[1])         // copy first argument to work with it
  19.       QueryDay[3] = 0                  // limit to search on first three letters
  20.       // case-inensitive (i.e., both string converted to upper-case) search for
  21.       // QueryDay in TimeString
  22.       if strstr(strupr(TimeString),strupr(QueryDay)) {
  23.          printf("Yes, today is %s\n",argv[1])
  24.          IsDay = 1
  25.       } else
  26.          printf("No, today is not %s\n",argv[1])
  27.    }
  28.    return IsDay
  29. }
  30.  
  31. ShowHelp() // This routine is called above if input seems invalid
  32. {
  33.    printf("\n\a")      // This makes an audible beep
  34.    printf("IsDay.bat - CMM program to check if it is a certain day of the week.\n")
  35.    printf("            Will print messages if it is or isn't, and return with\n")
  36.    printf("            ERRORLEVEL 1 if it is the requested day, and 0 if it is not.\n")
  37.    printf("            You must supply at least the first three letters of the day.\n")
  38.    printf("Example:\n")
  39.    printf("\tISDAY <Friday | Fri | FRI | FRICASSE>\n\n");
  40. }
  41.  
  42. :CENVI_EXIT
  43.